<% layout('/layouts/default.html', {title: '安全设置', libs: ['validate']}){ %>
<div class="card bd-0">
    <div class="card-header d-flex align-items-start justify-content-between box-header fixed">
        <div class="pt-1">安全设置</div>
        <div class="d-flex">

        </div>
    </div>
    <#form:form id="inputForm" model="${user}" action="${ctx}/sys/user/savePassData" method="post">
    	<#form:hidden path="userCode"/>
        <div class="card-body card-content-fixed pd-sm-t-30 pd-sm-b-40 pd-sm-x-30">
        	<div class="form-row">
	            <div class="form-group  col-md-12">
	                <label>当前登录账号 Username <span class="tx-danger ">*</span></label>
	                <#form:input path="username" maxlength="10" readonly="true" class="form-control"/>
	            </div>
	            <div class="form-group  col-md-12">
	                <label>旧的登录密码 Old Password <span class="tx-danger ">*</span></label>
                	<#form:input name="oldPassword" type="password"  maxlength="64"  class="form-control required" placeholder="请输入旧的登录密码" />
	            </div>
	            <div class="form-group  col-md-12">
	                <label>新登录密码 New Password <span class="tx-danger ">*</span></label>
                	<#form:input name="password"  type="password" id="passwordVal" maxlength="64"  class="form-control required" minlength="6" placeholder="请输入新登录密码" />
	            </div>
	            <div class="form-group  col-md-12">
	                <label>重复登录密码 Retype Password <span class="tx-danger ">*</span></label>
                	<#form:input name="repTypePassword"  type="password" id="repTypePasswordVal" maxlength="64"  class="form-control required"  placeholder="请输入重复登录密码" />
	            </div>
            </div>
        </div>
        <div class="card-footer pd-sm-l-30">
            <div class="row">
                <div class="col-sm-offset-2 col-sm-10">
                	<% if(expIf("hasAuthority('sys:user:edit')")){ %>
                    <button type="submit" class="btn btn-sm btn-primary">保存提交</button>
                    <% } %>
                    <button type="button" class="btn btn-sm btn-default" onclick="js.closeCurrentTabPage()">关闭窗口</button>
                </div>
            </div>
        </div>
    </#form:form>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		if($("#oldPassword").val()==$("#passwordVal").val()){
			js.alert('新密码不能和原密码一致！', {icon: 2});
			return false;
		}
		if($("#passwordVal").val()!=$("#repTypePasswordVal").val()){
			js.alert('两次密码输入不一致！', {icon: 2});
			return false;
		}
		
		// 提交表单数据
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage();
			}
		}, "json");
    }
});
</script>
</body></html>